home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1986 February / Ahoy_Magazine_86-02_1986_Double_L.d64 / simple comp. (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  996b  |  36 lines

  1. 0 rem << cd26-2 >>
  2. 1 rem  commodare #22-2 :
  3. 2 rem         simple comparison
  4. 3 rem  solutions by
  5. 4 rem    norm green (lines 100-130)
  6. 5 rem    frank smith (lines 200-250)
  7. 6 rem  & dennis furman (lines 300-350)
  8. 7 rem
  9. 10 data 1,2,3,4,5,6,7,8,9,10
  10. 20 data 10,9,8,7,6,5,4,3,2,2
  11. 30 for n=1 to 10 : read a(n) : next
  12. 40 for n=1 to 10 : read b(n) : next
  13. 50 ct=ct+1
  14. 60 on ct gosub 100,200,300
  15. 70 if ct<3 then 50
  16. 80 end
  17. 99 rem=================================
  18. 100 for n=1 to 10:xa=xa+a(n):ya=ya*a(n)
  19. 110 xb=xb+b(n) : yb=yb*b(n) : next
  20. 120 if xa=xb and ya=yb then print : print"match" : return
  21. 130 print"not a match" : return
  22. 199 rem================================
  23. 200 for c=1 to 10:for d=c to 10:ifa(c)<>b(d) then 220
  24. 210 h=b(c):b(c)=b(d):b(d)=h:goto 240
  25. 220 next d
  26. 230 print"the two sets are not the same":return
  27. 240 next c
  28. 250 print"the two sets contain the same numbers":return
  29. 299 rem================================
  30. 300 for i=1 to 10:forj=10 to i+1 step-1
  31. 310 if a(j)>a(j-1)thenc=a(j-1):a(j-1)=a(j):a(j)=c
  32. 320 if b(j)>b(j-1)thend=b(j-1):b(j-1)=b(j):b(j)=d
  33. 330 next j
  34. 340 ifa(i)<>b(i)then print"not equal":return
  35. 350 next i : print"equal":return
  36.